#include "echo.hpp"
#include <signal.h>
#include <atomic>

// 全局标志，用于优雅退出
// std::atomic<bool> g_running(true);

// void signal_handler(int signum)
// {
//     std::cout << "\nReceived signal " << signum << ", shutting down gracefully..." << std::endl;
//     g_running.store(false);
// }

int main()
{
    // 注册信号处理器，支持 Ctrl+C 优雅退出
    // signal(SIGINT, signal_handler);
    // signal(SIGTERM, signal_handler);

    EchoServer server(8500);

    std::cout << "Server started, listening on port 8500..." << std::endl;
    std::cout << "Press Ctrl+C to stop gracefully..." << std::endl;

    // 服务器会在 Start() 中阻塞
    server.Start();

    std::cout << "Server stopped." << std::endl;
    return 0;
}